const {merge}=require("webpack-merge")
const common=require("./webpack.common.js")
const CopyWebpackPlugin=require("copy-webpack-plugin")
const {CleanWebpackPlugin}=require("clean-webpack-plugin")

module.exports=merge(common,{
    mode:"production",
    devtool:false, //不需要source-map
    output:{
        filename:"[name]-[contenthash].bundle.js", //给文件加上hash码
    },
    module:{
        rules:[
            {   //用babel-loader转换js代码
                test:/\.js$/,
                use: ["babel-loader","eslint-loader"]
            }
        ],
    },
    plugins:[
        //把favicon.ico复制到输出目录
        new CopyWebpackPlugin({
            patterns:[
                {from:"./public/favicon.ico",to:"favicon.ico"}
            ]
        }),
        //清理dist文件夹
        new CleanWebpackPlugin(),
        
    ]
})